|
1
|
|
|
import React from 'react'; |
|
2
|
|
|
import LanguageContainer from '../Language/Container'; |
|
3
|
|
|
import ListenerAdapter from '../Observer/ListenerAdapter'; |
|
4
|
|
|
import Observer, {IObserverAdapter} from '../Observer/Observer'; |
|
5
|
|
|
import RouterContainer from '../Router/Container'; |
|
6
|
|
|
import Action from './Action'; |
|
7
|
|
|
import {IAdapter, IModulePageData} from './Application'; |
|
8
|
|
|
import ModuleLoader from './ModuleLoader'; |
|
9
|
|
|
import ApplicationPresenter from './View/Application/Presenter'; |
|
10
|
|
|
import PagePresenter from './View/Page/Presenter'; |
|
11
|
|
|
import SideMenuPresenter from './View/SideMenu/Presenter'; |
|
12
|
|
|
import TopBarPresenter from './View/TopBar/Presenter'; |
|
13
|
|
|
|
|
14
|
|
|
class Container { |
|
15
|
|
|
language: typeof LanguageContainer; |
|
16
|
|
|
router: typeof RouterContainer; |
|
17
|
|
|
applicationPresenter: ApplicationPresenter; |
|
18
|
|
|
topAppBarPresenter: TopBarPresenter; |
|
19
|
|
|
applicationAction: Action; |
|
20
|
|
|
menuOpenStateAdapter: IObserverAdapter<boolean>; |
|
21
|
|
|
menuOpenState: Observer<boolean>; |
|
22
|
|
|
sideMenuPresenter: SideMenuPresenter; |
|
23
|
|
|
moduleStateAdapter: ListenerAdapter<typeof React.Component | null>; |
|
24
|
|
|
moduleState: Observer<typeof React.Component | null>; |
|
25
|
|
|
moduleLoader: ModuleLoader; |
|
26
|
|
|
pagePresenter: PagePresenter; |
|
27
|
|
|
applicationActionAdapter: IAdapter; |
|
28
|
|
|
|
|
29
|
|
|
constructor() { |
|
30
|
1 |
|
this.language = LanguageContainer; |
|
31
|
1 |
|
this.router = RouterContainer; |
|
32
|
|
|
|
|
33
|
1 |
|
this.menuOpenStateAdapter = {onChange: ((oldValue, newValue) => {})}; |
|
34
|
1 |
|
this.menuOpenState = new Observer<boolean>(false, this.menuOpenStateAdapter); |
|
35
|
|
|
|
|
36
|
1 |
|
this.moduleStateAdapter = new ListenerAdapter<typeof React.Component | null>(); |
|
37
|
1 |
|
this.moduleState = new Observer<typeof React.Component | null>(null, this.moduleStateAdapter); |
|
38
|
1 |
|
this.moduleLoader = new ModuleLoader('../', this.moduleState); |
|
39
|
|
|
|
|
40
|
1 |
|
this.applicationAction = |
|
41
|
|
|
new Action(this.menuOpenState, this.router.router, this.router.registry, this.moduleLoader); |
|
42
|
1 |
|
this.applicationActionAdapter = this.applicationAction.adapter; |
|
43
|
|
|
|
|
44
|
1 |
|
this.topAppBarPresenter = new TopBarPresenter(this.language.observer); |
|
45
|
1 |
|
this.sideMenuPresenter = |
|
46
|
|
|
new SideMenuPresenter(this.menuOpenState, this.language.observer, this.router.observer, this.router.registry); |
|
47
|
1 |
|
this.pagePresenter = new PagePresenter(this.moduleState); |
|
48
|
1 |
|
this.applicationPresenter = new ApplicationPresenter( |
|
49
|
|
|
this.language.observer, |
|
50
|
|
|
this.topAppBarPresenter, |
|
51
|
|
|
this.sideMenuPresenter, |
|
52
|
|
|
this.pagePresenter |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
1 |
|
this.setupDefaults(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected setupDefaults(): void { |
|
59
|
|
|
|
|
60
|
1 |
|
this.router.adapter.addListener(this.applicationActionAdapter.onPageChanged); |
|
61
|
1 |
|
this.language.changeLanguageSetup.interact({languageCode: 'de-de'}, {}).then(); |
|
62
|
1 |
|
const homePage: IModulePageData = { |
|
63
|
|
|
depth: 0, |
|
64
|
|
|
name: 'home', |
|
65
|
|
|
url: './', |
|
66
|
|
|
module: './HelloWorld' |
|
67
|
|
|
}; |
|
68
|
1 |
|
const settingsPage: IModulePageData = { |
|
69
|
|
|
depth: 1, |
|
70
|
|
|
name: 'settings', |
|
71
|
|
|
url: './settings/', |
|
72
|
|
|
module: './Settings/Settings' |
|
73
|
|
|
}; |
|
74
|
1 |
|
this.router.registry.registerPage(homePage); |
|
75
|
1 |
|
this.router.registry.registerPage(settingsPage); |
|
76
|
1 |
|
this.router.observer.value = homePage; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
export default new Container(); |